<template>
	<view>
		<uni-search-bar placeholder="搜索公益" @confirm="shou"></uni-search-bar>
		<u-swiper :height="250" :list="lun" :effect3d="true" :interval="3000" @click="click"></u-swiper>

		<uni-group title="公益分类">
			<view class="item-container">
				<view class="thumb-box" v-for="(item1, index1) in fen" @click="dianji(item1.id)" :key="index1">
					<image class="item-menu-image" :src="base+item1.imgUrl" mode=""></image>
					<view class="item-menu-name">{{item1.name}}</view>
				</view>
			</view>
		</uni-group>
		<uni-group title="推荐公益列表">
			<uni-card v-for="(item,index) in gonglist" :title="item.name" @click="xian(item.name)" >
				<image :src="base+item.imgUrl" style="width: 100%;"></image>
				<view>发布组织:{{item.author}}</view>
				<view>捐赠人数:{{item.donateCount}}</view>
				<view>已筹善款:{{item.moneyNow}}元</view>
			</uni-card>
		</uni-group>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				lun: [],
				fen: [],
				gonglist:[]
			}
		},
		onLoad() {
			this.getlun()
			this.getlun2()
			this.getlun3()
		},
		methods: {
			xian(name){
				uni.navigateTo({
					url:'xianq?id='+name
				})
			},
			shou(e){
				uni.navigateTo({
					url:'fenlist?name='+e.value
				})
			},
			dianji(id){
				uni.navigateTo({
					url:'fenlist?id='+id
				})
			},
			getlun() {
				this.$get(this.base + '/prod-api/api/public-welfare/ad-banner/list').then((res) => {
					res.data.forEach((item) => {
						this.lun.push({
							image: this.base + item.imgUrl,
							id: item.id
						})
					})
				})
			},
			getlun2() {
				this.$get(this.base + '/prod-api/api/public-welfare/public-welfare-type/list').then((res) => {
					this.fen = res.data
				})
			},
			getlun3() {
				this.$get(this.base + '/prod-api/api/public-welfare/public-welfare-activity/recommend-list').then((res) => {
					this.gonglist = res.rows
				})
			},
		}
	}
</script>

<style>
	.item-container {
			display: flex;
			flex-wrap: wrap;
		}
	
		.thumb-box {
			width: 25%;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			margin-top: 20rpx;
		}
	
		.item-menu-image {
			width: 60rpx;
			height: 60rpx;
		}
</style>
